'''
Created on Feb 7, 2013

@author: Artur
'''

from matplotlib import pyplot as plt

def ResultFile():
    f = open('data')
    r = []
    for line in f:
        tok = line.split(',')
        r.append([int(tok[0])] + [float(x) for x in tok[1:]])
    f.close()
    
    return r
    
    
def PlotRuntime(r):

    plt.figure(1, facecolor='w', dpi=120, figsize = (10., 5.))
    
    x = [n[0] for n in r]
    
    y = [n[1] for n in r]
    plt.plot(x, y, '--r', lw=3.0, ms=9.0, label="Sort KeyPrep")
    y = [n[2] for n in r]
    plt.plot(x, y, '-rx', lw=3.0, ms=7.0, label="Sort Total")
    
    y = [n[3] for n in r]
    plt.plot(x, y, '--g', lw=3.0, ms=9.0, label="BitMap KeyPrep")
    y = [n[4] for n in r]
    plt.plot(x, y, '-g^', lw=3.0, ms=7.0, label="BitMap Total")
    
    
    plt.xlabel('Number of characters')
    plt.ylabel('Running time (sec)')
    plt.title('GroupAnagrams #Characters Scalability at N = 100,000, CharRange = 256')
    
    plt.legend(loc=2)

    plt.show()
    
    

PlotRuntime(ResultFile())